package com.marktotop.chapter4;

import com.alibaba.druid.pool.DruidDataSource;
import com.marktotop.chapter4.config.SpringConfig;
import com.marktotop.chapter4.entity.TbUser;
import com.marktotop.chapter4.service.TbUserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author WXLD
 * @data 2021/4/26 - 10:33
 */
public class App {

    public static void main(String[] args){
        /* 使用注解加载方法 */
        ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
//        DruidDataSource dataSource = (DruidDataSource) context.getBean("dataSource");
//        System.out.println(dataSource);
        TbUserService tbuserService = (TbUserService) context.getBean("tbUserService");
        TbUser one = tbuserService.getOne(2);
        System.out.println(one);
    }
}
